package cn.ldh.controller;

import cn.ldh.block.UserBlock;
import cn.ldh.domain.User;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.sun.deploy.security.BlockedException;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.PublicKey;


@RestController
@RequestMapping("/user")
@RefreshScope
public class UserController {

    @GetMapping("/getById/{id}")
    //@SentinelResource(value = "user-server",blockHandler = "exceptionHandler", blockHandlerClass= UserBlock.class)
    public User getById(@PathVariable("id") Long id) {

        return new User(id, "帅帅", "哈哈哈哈哈哈");

    }

//    public User exceptionHandler(@PathVariable("id") Long id, BlockException e) {
//        e.printStackTrace();
//        return new User(-1L, "限流触发", "限流了");
//    }



}
